/*------------------易分析监控代码------------------*/
var _trackDataType = 'web'; //标记数据来源，参数是web和wap，可以为空，默认是web
var _Schannel_website_id = '';//分站编号，不存在可不写此变量或者留空
var _Schannel_webshop_id = '';//商铺编号，不存在可不写此变量或者留空
var _trackData = _trackData || [];//必须为全局变量，假如之前并没有声明，请加此行代码；



//*推荐商品列表-易分析*//
function recommend_track(){
	var gcodes_in_cart = [];
	$("#main_table tr").each(function(){
		var code = $(this).attr('gcode');
		if(code){
			gcodes_in_cart.push(code);
		}
	});	
	var recommend = [];
	$('#bc_prolist .bc_btn').each(function(){
		var code = $(this).attr('gcode');
		if(code){
			recommend.push(code);
		}
	});
	if(recommend.length == 0){
		return;
	}
	var maingcodes = gcodes_in_cart.join('|');
	var finalstr = []; 
	for(var i=0; i < recommend.length; i++){
		var entry = 'latag_pc_cart_buy_rec_' + (i+1) + '__' + recommend[i] ;//latag_pc_cart_recommend_
		finalstr.push(entry); 
	}
	
	_trackData.push(['show','goodsid', maingcodes, finalstr.join(',')]);
}

var laurl =  ssoassetModule + "/la/la.min.js";

function loadScript(url, callback) {
    var script = document.createElement("script")
    script.type = "text/javascript";
    if (script.readyState) { //IE
        script.onreadystatechange = function () {
            if (script.readyState == "loaded" ||
                script.readyState == "complete") {
                script.onreadystatechange = null;
                callback();
            }
        };
    } else { //Others: Firefox, Safari, Chrome, and Opera
        script.onload = function () {
            callback();
        };
    }
    script.src = url;
    document.body.appendChild(script);
}

$(function () {
    loadScript(laurl, function () {
        if (typeof (la_callback) != 'undefined' && la_callback) {
            la_callback();
        }
    });
});
/*------------------end------------------*/


/************piwik监控代码piwik_new_begin*********************/
//URL
//var global_monitorurl = "//shop.click.lenovo.com.cn/collect";
//var global_monitorjs = "//shop.click.lenovo.com.cn/analytics.js";
//if  (plat== 4  ) {  //pc
//    var global_monitorid = 18;
//} else if(plat == 8) {  //think
//    var global_monitorid = 53;
//} else if (plat == 22){  //epp
//    var global_monitorid = 56;
//}
//
//var _paq = _paq || [];
//function piwik_loadScript(url, callback) {
//    var script = document.createElement('script');
//    script.type = 'text/javascript';
//    if (callback)
//        script.onload = script.onreadystatechange = function () {
//            if (script.readyState && script.readyState != 'loaded' && script.readyState != 'complete')
//                return;
//            script.onreadystatechange = script.onload = null;
//            callback();
//        };
//    script.src = url;
//    document.getElementsByTagName('head')[0].appendChild(script);
//}
//
//function piwik_pc_track_event(category, action, json_data) {
//    try {
//        var obj = Piwik.getAsyncTracker();
//        obj.setCustomData(json_data);
//        obj.setSiteId(global_monitorid);
//        obj.trackEvent(category, action, 'data', 1);
//    } catch (err) {
//        if (console) {
//            console.log(err);
//        }
//    }
//}
//
//function piwik_pc_track(json_data) {
//    try {
//        var obj = Piwik.getAsyncTracker();
//        obj.setSiteId(global_monitorid);
//        obj.setTrackerUrl(global_monitorurl);
//        obj.enableLinkTracking();
//        obj.setCustomData(json_data);
//        obj.trackPageView();
//    } catch (err) {
//        if (console) {
//            console.log(err);
//        }
//    }
//}
//
//var lenovoid;
//try{
//    if (null != passport.cookie.lenovoId  &&  "undefined" != passport.cookie.lenovoId) {
//        lenovoid = passport.cookie.lenovoId;
//    }
//}catch(err){
//    console.log(err);
//}
//if (typeof lenovoid != "undefined") {
//    var piwik_data = { "lenovoid": lenovoid }
//}
//function piwik_callback() {
//    var json_data = {};
//    if (typeof piwik_data != "undefined") {
//        json_data = piwik_data;
//    }
//    if (typeof page_id != "undefined") {
//        json_data["page_id"] = page_id;
//    }
//    json_data["page_type"] = "pc";
//    piwik_pc_track(json_data);
//}
//
//$(function () {
//    piwik_loadScript(global_monitorjs, piwik_callback);
//});

/******************piwik_new_end*******************/